/*
 * menu.java
 *
 * Created on 20 de noviembre de 2008, 14:02
 */
package Vistas;

import java.io.IOException;
import java.io.StreamCorruptedException;
import Dominio.CtrlDominio;
import java.awt.Desktop;
import java.io.File;
import javax.swing.JOptionPane;

/**
 *
 * @author  kaolla86
 */
public class menu extends javax.swing.JFrame {

    private int idioma;
    private CtrlDominio CD = CtrlDominio.getInstance();
    private String fs = System.getProperty("file.separator");

    /** Creates new form menu */
    public menu(int i) {
        initComponents();
        idioma = i;
        this.setTitle("Main principal");
        this.setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jBtNotMan = new javax.swing.JButton();
        jBtNotAuto = new javax.swing.JButton();
        jBtConsNot = new javax.swing.JButton();
        jBtConsTema = new javax.swing.JButton();
        jBtManual = new javax.swing.JButton();
        jBtCreditos = new javax.swing.JButton();
        jBtSalir = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jSecciones = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jBtNotMan.setText("Clasificar Noticia Manualmente");
        jBtNotMan.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBtNotManMouseClicked(evt);
            }
        });

        jBtNotAuto.setText("Clasificar Noticia Automáticamente");
        jBtNotAuto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBtNotAutoMouseClicked(evt);
            }
        });
        jBtNotAuto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtNotAutoActionPerformed(evt);
            }
        });

        jBtConsNot.setText("Consultar Noticia Clasificada");
        jBtConsNot.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBtConsNotMouseClicked(evt);
            }
        });
        jBtConsNot.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtConsNotActionPerformed(evt);
            }
        });

        jBtConsTema.setText("Consultar Temas");
        jBtConsTema.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBtConsTemaMouseClicked(evt);
            }
        });

        jBtManual.setText("Consultar Manual de Usuario");
        jBtManual.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBtManualMouseClicked(evt);
            }
        });

        jBtCreditos.setText("Créditos");
        jBtCreditos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBtCreditosMouseClicked(evt);
            }
        });
        jBtCreditos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtCreditosActionPerformed(evt);
            }
        });

        jBtSalir.setText("Salir");
        jBtSalir.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBtSalirMouseClicked(evt);
            }
        });

        jButton1.setText("Consultar Palabras");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jSecciones.setText("Consultar Secciones");
        jSecciones.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jSeccionesMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                    .addComponent(jBtNotMan, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                    .addComponent(jBtConsNot, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                    .addComponent(jBtNotAuto, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                    .addComponent(jBtConsTema, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                    .addComponent(jBtSalir, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                    .addComponent(jSecciones, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                    .addComponent(jBtManual, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                    .addComponent(jBtCreditos, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jBtNotMan)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBtNotAuto)
                .addGap(12, 12, 12)
                .addComponent(jBtConsNot)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBtConsTema)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSecciones)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBtManual)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(jBtCreditos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBtSalir)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(42, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    private void jBtConsNotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtConsNotActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jBtConsNotActionPerformed

    private void jBtConsNotMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBtConsNotMouseClicked
        try {
            this.dispose();
            new ConsNoticias(idioma).setVisible(true);
        } catch (StreamCorruptedException ex) {
        //Logger.getLogger(menu.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
        //Logger.getLogger(menu.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
        //Logger.getLogger(menu.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_jBtConsNotMouseClicked
    
private void jBtSalirMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBtSalirMouseClicked
    if(idioma==1)    {
   JOptionPane.showMessageDialog(this, "Guardando los diccionarios de Espa\u00f1ol... esta operaci\u00f3n puede tardar unos segundos", "La operaci\u00f3n puede tardar", JOptionPane.INFORMATION_MESSAGE);
        CD.actualizar(System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DNesp.dicc",System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DPesp.dicc",System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DTesp.dicc", System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DNFesp.dicc");
   }else if(idioma ==2){
   JOptionPane.showMessageDialog(this, "Guardando los diccionarios de Catal\u00e1n... esta operaci\u00f3n puede tardar unos segundos", "La operaci\u00f3n puede tardar", JOptionPane.INFORMATION_MESSAGE);
       CD.actualizar(System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DNcat.dicc",System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DPcat.dicc",System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DTcat.dicc", System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DNFcat.dicc");
   }else if(idioma==3){
       JOptionPane.showMessageDialog(this, "Guardando los diccionarios de Ingl\u00e9s... esta operaci\u00f3n puede tardar unos segundos", "La operaci\u00f3n puede tardar", JOptionPane.INFORMATION_MESSAGE);
       CD.actualizar(System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DNing.dicc",System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DPing.dicc",System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DTing.dicc", System.getProperty("user.dir")+fs+"src"+fs+"Diccionarios"+fs+"DNFing.dicc");
   }
    System.exit(0);
}//GEN-LAST:event_jBtSalirMouseClicked

            private void jBtNotManMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBtNotManMouseClicked
                this.setVisible(false);
                new NotManual(idioma).setVisible(true); 
}//GEN-LAST:event_jBtNotManMouseClicked

            private void jBtNotAutoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBtNotAutoMouseClicked
                this.dispose();
                new NoticiaAutomatica(idioma).setVisible(true);                 // TODO add your handling code here:
            }//GEN-LAST:event_jBtNotAutoMouseClicked

            private void jBtConsTemaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBtConsTemaMouseClicked
                this.dispose();
                new ConsultarTema(idioma).setVisible(true);                 // TODO add your handling code here:
            }//GEN-LAST:event_jBtConsTemaMouseClicked

            private void jBtCreditosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBtCreditosMouseClicked
                this.dispose();
                new Creditos(idioma).setVisible(true);                  // TODO add your handling code here:
            }//GEN-LAST:event_jBtCreditosMouseClicked

            private void jBtCreditosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtCreditosActionPerformed
                // TODO add your handling code here:
            }//GEN-LAST:event_jBtCreditosActionPerformed

            private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
                this.dispose();
                new ConsPalabras(idioma).setVisible(true);
            }//GEN-LAST:event_jButton1MouseClicked

private void jBtNotAutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtNotAutoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jBtNotAutoActionPerformed

private void jBtManualMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBtManualMouseClicked
try {
            File path = new File(System.getProperty("user.dir") + fs +"src"+ fs+"manual.pdf");
            Desktop.getDesktop().open(path);
        } catch (IOException ex) {
  JOptionPane.showMessageDialog(this,"Se ha producido un error al abrir el manual","Error al abrir el manual",JOptionPane.INFORMATION_MESSAGE);
        }catch(IllegalArgumentException ex){
            JOptionPane.showMessageDialog(this, "No se puede visualizar el manual de usuario porque se ha movido o borrado el manual", "Error: no se puede visualizar el manual", JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jBtManualMouseClicked

private void jSeccionesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jSeccionesMouseClicked
      this.dispose();
      new ConsultarSeccion(idioma).setVisible(true);
}//GEN-LAST:event_jSeccionesMouseClicked
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtConsNot;
    private javax.swing.JButton jBtConsTema;
    private javax.swing.JButton jBtCreditos;
    private javax.swing.JButton jBtManual;
    private javax.swing.JButton jBtNotAuto;
    private javax.swing.JButton jBtNotMan;
    private javax.swing.JButton jBtSalir;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton jSecciones;
    // End of variables declaration//GEN-END:variables
    
}
